package com.atguigu.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/hello")
public class ThymeleafHelloWrodController {
    @RequestMapping({"/", "/index"})
    @ResponseBody
    public String index(Model model, String id) {
        model.addAttribute("msg", "welcome you!" + id);

        Map<String,String> user = new HashMap<>();
        user.put("uid","11111");
        user.put("umc","testmc");
        user.put("etel","13550125501");
        model.addAttribute("user", user);
        return "index"; //返回的是index.html的页面
    }

    @RequestMapping("/thymeleaf")
    public String helloThymeleaf(Model model){
        model.addAttribute("hello","hello Thymeleaf！");
        return "hello/index";
    }
}

